﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Data;
using MathematicallySafe.HeadCounter.Data;
using MathematicallySafe.HeadCounter.Data.Common;
using MathematicallySafe.HeadCounter.Data.Interfaces;
using StructureMap;

namespace MathematicallySafe.HeadCounter.ViewModels
{
    public class RosterViewModel: ViewModelBase
    {
        private static readonly IGuild Guild = ObjectFactory.GetInstance<IGuild>();

        private ObservableCollection<RaiderViewModel> _raiders;

        public ListCollectionView Raiders { get; private set; }
        private readonly SortDescription ByNameAscending = new SortDescription("Name", ListSortDirection.Ascending);

        public RosterViewModel()
        {
            LoadRaiders();
        }

        private void LoadRaiders()
        {
            _raiders = new ObservableCollection<RaiderViewModel>();
            Guild.RaidersByMain.ForEach(r => _raiders.Add(new RaiderViewModel(r)));

            Raiders = new ListCollectionView(_raiders);
            Raiders.SortDescriptions.Add(ByNameAscending);
        }

    }
}
